﻿using System;
using System.IO;

class MaxSumInMatrix
{
    static int bestSum;

    static void Main()
    {
        using (StreamReader input = new StreamReader("input.txt"))
        {
            int n = int.Parse(input.ReadLine());
            int[,] array = new int[n, n];

            for (int i = 0; i < array.GetLength(0); i++)
            {
                string[] numbers = input.ReadLine().Split(' ');

                for (int j = 0; j < array.GetLength(1); j++)
                {
                    array[i, j] = int.Parse(numbers[j]);
                }
            }

            for (int i = 0; i <= array.GetLength(0) - 2; i++)
            {
                for (int j = 0; j <= array.GetLength(1) - 2; j++)
                {
                    MaximumSum(array, i, j);
                }
            }

            using (StreamWriter output = new StreamWriter("output.txt"))
            {
                output.Write(bestSum);
            }
        }
    }

    private static void MaximumSum(int[,] array, int startX, int startY)
    {
        int[,] candidateMatrix = new int[2, 2];
        int candidateSum = 0;

        for (int i = startX; i < startX + 2; i++)
        {
            for (int j = startY; j < startY + 2; j++)
            {
                candidateMatrix[i - startX, j - startY] = array[i, j];
                candidateSum += array[i, j];
            }
        }
        if (candidateSum > bestSum)
        {
            bestSum = candidateSum;
        }
    }
}